<!DOCTYPE html>
<html lang="zh">

<head>
    <title></title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="https://cdn.staticfile.net/vue/2.7.8/vue.js"></script>
    <link href="../css/style.css" rel="stylesheet">
</head>

<body>
<div id="app">
    <p>
        今年3月3日发卖的任天堂新一代主机Switch的价格是：{{price}}円，含税价格为：{{priceInTax}}円，折合人民币为：{{priceChinaRMB}}元。
    </p>

    <button type="button" v-on:click="change()"> commit</button>
</div>
<script>
    const vm = new Vue({
        el: '#app',
        data: {
            price: 29980
            // priceInTax: 0,
            // priceChinaRMB: 0,
        },
        methods: {
            change: function () {
                this.price = Math.floor(Math.random() * 1000);
            }
        },
        computed: {
            priceInTax: {
                get: function () {
                    return this.price * 1.08;
                },
                set: function (val) {
                    this.price = val * 1.08;
                }
            },
            priceChinaRMB: function () {
                return Math.round(this.priceInTax * 16.75);
            }
        }
    });
</script>
</body>
</html>